from flask_restplus import Resource, reqparse, fields
from flask import request
from core.app import api

ns = api.namespace('todos', description='TODO operations')

login_params = api.model('Resource', {
    'name': fields.String(required=True, description="用户名"),
    'password': fields.String
})


@ns.route('/auth')
class LoginView(Resource):
    @ns.doc(security='apiKey')
    @ns.param("name", "用户名", required=True)
    @ns.param("password", "密码", required=True)
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('name', type=str, help='Rate to charge for this resource')
        parser.add_argument('password', type=str, help='password ')
        parser.add_argument("data", type=str)
        args = parser.parse_args()
        return args
